

function calculateCarbon() {
    // 假设的碳排放系数
    const distanceFactor = 0.2; // 每公里行驶的碳排放量
    const publicTransportFactor = 5; // 每次使用公共交通的碳排放量
    const meatFactor = 27; // 每公斤肉类的碳排放量

    // 获取用户输入
    const distance = document.getElementById('distance').value;
    const publicTransport = document.getElementById('publicTransport').value;
    const meatConsumption = document.getElementById('meatConsumption').value;

    // 计算碳排放
    const carbonEmission = (distance * distanceFactor) + 
                           (publicTransport * publicTransportFactor) + 
                           (meatConsumption * meatFactor);

    // 显示结果
    const resultDiv = document.getElementById('result');
    resultDiv.innerHTML = `<strong>您的碳排放量约为：${carbonEmission.toFixed(2)} kg CO2</strong>`;
}
